package com.xyzwps.server.paimon.infra.service

import com.xyzwps.server.paimon.common.Utils
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class VcodeGeneratorConfiguration {

    @ConditionalOnProperty(name = ["paimon.config.vcode-generator"], havingValue = "666666")
    @Bean
    fun fixed666666VcodeGenerator(): VcodeGenerator {
        return VcodeGenerator { "666666" }
    }

    @ConditionalOnMissingBean(VcodeGenerator::class)
    @Bean
    fun randomVcodeGenerator(): VcodeGenerator {
        return VcodeGenerator { Utils.genVcode6() }
    }
}
